/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Pengeluaran;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import tools.koneksi;

/**
 *
 * @author w7
 */
public class Pengeluaran {
    private String noInvoice;
    private Date tanggal;
    private String IDunit;
     private String namaUnit;
    private Double jumlahMintaDana;
    private String kodeRekening;
    private String noRD;
    private String kebutuhanRD;
    private String jumlahRD;
    private Double hargaRD;
    private String keterangan;
    private String detail;


    /**
     * @return the tanggal
     */
    public Date getTanggal() {
        return tanggal;
    }

    /**
     * @param tanggal the tanggal to set
     */
    public void setTanggal(Date tanggal) {
        this.tanggal = tanggal;
    }

    /**
     * @return the IDunit
     */
    public String getIDunit() {
        return IDunit;
    }

    /**
     * @param IDunit the IDunit to set
     */
    public void setIDunit(String IDunit) {
        this.IDunit = IDunit;
    }

    /**
     * @return the jumlahMintaDana
     */
    public Double getJumlahMintaDana() {
        return jumlahMintaDana;
    }

    /**
     * @param jumlahMintaDana the jumlahMintaDana to set
     */
    public void setJumlahMintaDana(Double jumlahMintaDana) {
        this.jumlahMintaDana = jumlahMintaDana;
    }

    /**
     * @return the kodeRekening
     */
    public String getKodeRekening() {
        return kodeRekening;
    }

    /**
     * @param kodeRekening the kodeRekening to set
     */
    public void setKodeRekening(String kodeRekening) {
        this.kodeRekening = kodeRekening;
    }

   
    /**
     * @return the kebutuhanRD
     */
    public String getKebutuhanRD() {
        return kebutuhanRD;
    }

    /**
     * @param kebutuhanRD the kebutuhanRD to set
     */
    public void setKebutuhanRD(String kebutuhanRD) {
        this.kebutuhanRD = kebutuhanRD;
    }

  
    /**
     * @return the hargaRD
     */
    public Double getHargaRD() {
        return hargaRD;
    }

    /**
     * @param hargaRD the hargaRD to set
     */
    public void setHargaRD(Double hargaRD) {
        this.hargaRD = hargaRD;
    }

    /**
     * @return the noInvoice
     */
    public String getNoInvoice() {
        return noInvoice;
    }

    /**
     * @param noInvoice the noInvoice to set
     */
    public void setNoInvoice(String noInvoice) {
        this.noInvoice = noInvoice;
    }

    /**
     * @return the namaUnit
     */
    public String getNamaUnit() {
        return namaUnit;
    }

    /**
     * @param namaUnit the namaUnit to set
     */
    public void setNamaUnit(String namaUnit) {
        this.namaUnit = namaUnit;
    }

    /**
     * @return the noRD
     */
    public String getNoRD() {
        return noRD;
    }

    /**
     * @param noRD the noRD to set
     */
    public void setNoRD(String noRD) {
        this.noRD = noRD;
    }

    /**
     * @return the jumlahRD
     */
    public String getJumlahRD() {
        return jumlahRD;
    }

    /**
     * @param jumlahRD the jumlahRD to set
     */
    public void setJumlahRD(String jumlahRD) {
        this.jumlahRD = jumlahRD;
    }

    /**
     * @return the keterangan
     */
    public String getKeterangan() {
        return keterangan;
    }

    /**
     * @param keterangan the keterangan to set
     */
    public void setKeterangan(String keterangan) {
        this.keterangan = keterangan;
    }

    /**
     * @return the detail
     */
    public String getDetail() {
        return detail;
    }

    /**
     * @param detail the detail to set
     */
    public void setDetail(String detail) {
        this.detail = detail;
    }
    
   public final String no_invoice(){
       try {
            String sql = "select max(No_invoice) from Pengeluaran";
            Connection con = koneksi.getDBConnection();
            java.sql.Statement sta = con.createStatement();
            ResultSet rs = sta.executeQuery(sql);

            rs.next();
            String result = rs.getString(1);
            if (result != null) {
                int no = Integer.parseInt(result);
                no++;
                sql = "" + no;
                while (sql.length() <= 3) {
                    sql = "0" + sql;
                }
            } else {
                sql = "0001";
            }
            return sql;
        } catch (SQLException ex) {
            Logger.getLogger(Pengeluaran.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }

   }


}
